package com.bluesimon.wbf.usercenter;

import com.bluesimon.wbf.IUser;
import org.ume.school.modules.utils.TimeUtils;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * `user_id` varchar(64) NOT NULL COMMENT '会员id',
 * `user_name` varchar(64) DEFAULT NULL COMMENT '会员名称',
 * `nick_name` varchar(64) DEFAULT NULL COMMENT '会员昵称',
 * `real_name` varchar(64) DEFAULT NULL COMMENT '真实姓名',
 * `sex` tinyint(4) DEFAULT NULL COMMENT '0：保密；1.男，2女',
 * `email` varchar(128) DEFAULT NULL COMMENT '邮箱',
 * `mobile_phone` varchar(20) DEFAULT NULL COMMENT '手机号码',
 * `wechat_name` varchar(30) DEFAULT NULL COMMENT '微信账号名',
 * `referrer_id` bigint(20) DEFAULT NULL COMMENT '最近一级推荐者id',
 * `presenter_list` varchar(512) DEFAULT NULL COMMENT '推荐关系链（json）:[{"referrer_id":324332},{"referrer_id":787},......]。按推荐的层级排序，最左边那边是最近的一级',
 * `level` int(11) DEFAULT NULL COMMENT '会员级别',
 * `referrer_url` varchar(512) DEFAULT NULL COMMENT '邀请链接',
 * `status` tinyint(4) DEFAULT NULL COMMENT '删除标记0：可用；1、已删除；2、禁用',
 * `last_modified` timestamp NULL DEFAULT NULL COMMENT '创建时间',
 * Created by Django on 2017/8/6.
 */
@Entity
@Table(name = "uc_user_info")
public class User implements IUser, Serializable {

    @Column(name = "user_id", columnDefinition = "varchar(64) NOT NULL COMMENT '会员id'")
    @Id
    private String id;
    @Column(name = "user_name", columnDefinition = "varchar(64) DEFAULT NULL COMMENT '会员名称'")
    private String userName;
    @Column(name = "nick_name", columnDefinition = "varchar(64) DEFAULT NULL COMMENT '会员昵称'")
    private String nickName;
    @Column(name = "real_name", columnDefinition = "varchar(64) DEFAULT NULL COMMENT '真实姓名'")
    private String realName;
    @Column(name = "sex", columnDefinition = "tinyint(4) DEFAULT NULL COMMENT '0：保密；1.男，2女'")
    private Integer sex = 0;
    @Column(name = "email", columnDefinition = "varchar(128) DEFAULT NULL COMMENT '邮箱'")
    private String email;
    @Column(name = "mobile_phone", columnDefinition = "varchar(20) DEFAULT NULL COMMENT '手机号码'")
    private String mobilePhone;
    @Column(name = "wechat_name", columnDefinition = "varchar(30) DEFAULT NULL COMMENT '微信账号名'")
    private String wechatName;
    @Column(name = "referrer_id", columnDefinition = "varchar(64) DEFAULT NULL COMMENT '最近一级推荐者id'")
    private String referrerId;
    @Column(name = "presenter_list", columnDefinition = "varchar(512) DEFAULT NULL COMMENT '邀请链接'")
    private String presenterList;
    @Column(name = "level", columnDefinition = " int(11) DEFAULT NULL COMMENT '会员级别'")
    private Integer level = 0;
    @Column(name = "referre_url", columnDefinition = " varchar(512) DEFAULT NULL COMMENT '推荐关系链（json）:[{\"referrer_id\":324332},{\"referrer_id\":787},......]。按推荐的层级排序，最左边那边是最近的一级'")
    private String referreUrl;
    @Column(name = "status", columnDefinition = " tinyint(4) DEFAULT NULL COMMENT '删除标记0：可用；1、已删除；2、禁用'")
    private Integer status;
    @Column(name = "last_modified", columnDefinition = " timestamp NULL DEFAULT NULL COMMENT '创建时间'")
    private Date lastModified;
    @Column(name = "password", columnDefinition = " varchar(64) NULL DEFAULT NULL COMMENT '密码'")
    private String password;
    @Column(name = "head_image", columnDefinition = " varchar(128) NULL DEFAULT NULL COMMENT '头像'")
    private String headImage;

    @Column(name = "type", columnDefinition = " tinyint(4) DEFAULT 0 COMMENT ' 1、超级管理员（所有权限）；2、一般内部用户 ；  0: 外部注册用户 ; 3 外部关联用户(微信等)'")
    private Integer type;

    @Column(name = "summary", columnDefinition = " varchar(1024) NULL DEFAULT NULL COMMENT '简介'")
    private String summary;

    @Column(name = "city", columnDefinition = " varchar(64) NULL DEFAULT NULL COMMENT '所在城市'")
    private String city;

    @Column(name = "addr", columnDefinition = " varchar(1024) NULL DEFAULT NULL COMMENT '所在城市'")
    private String addr;

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getAddr() {
        return addr;
    }

    public void setAddr(String addr) {
        this.addr = addr;
    }

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public String getUserName() {
        return this.userName;
    }

    @Override
    public List<String> getRole() {
        return new ArrayList<String>();
    }

    public void setId(String id) {
        this.id = id;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobilePhone() {
        return mobilePhone;
    }

    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }

    public String getWechatName() {
        return wechatName;
    }

    public void setWechatName(String wechatName) {
        this.wechatName = wechatName;
    }

    public String getReferrerId() {
        return referrerId;
    }

    public void setReferrerId(String referrerId) {
        this.referrerId = referrerId;
    }

    public String getPresenterList() {
        return presenterList;
    }

    public void setPresenterList(String presenterList) {
        this.presenterList = presenterList;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(Integer level) {
        this.level = level;
    }

    public String getReferreUrl() {
        return referreUrl;
    }

    public void setReferreUrl(String referreUrl) {
        this.referreUrl = referreUrl;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getLastModified() {
        return lastModified;
    }

    public void setLastModified(Date lastModified) {
        this.lastModified = lastModified;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getHeadImage() {
        return headImage;
    }

    public void setHeadImage(String headImage) {
        this.headImage = headImage;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    @Transient
    private String sdate;

    public String getSdate() {
        if (null != this.getLastModified()) {
            sdate = TimeUtils.parseNLPattern(this.getLastModified());
        }
        return sdate;
    }

    public void setSdate(String sdate) {
        this.sdate = sdate;
    }
}
